﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using VideoClassLibrary.BusinessLogicLayer;
using System.Web.UI.HtmlControls;
using VideoClassLibrary.Model;

public partial class CourseListManagement_SearchClassRoomList : AdminUserBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            bindPageData();
        }
       
    }
    protected void btnfind_Click(object sender, EventArgs e)
    {
        //根据查询条件获取教室信息
        int schoolId = this.CurrentUser.SchoolID;
        ClassRoomModule crm = new ClassRoomModule();
        string roomName = this.txtroomName.Text.Trim().ToString();
        DataSet ds = crm.GetList(roomName, schoolId);
        Repeater1.DataSource = ds;
        Repeater1.DataBind();
        
    }
    protected void pager_PageChanged(object sender, EventArgs e)
    {
        bindPageData();
    }

    private void bindPageData()
    {
        ClassRoomModule crm = new ClassRoomModule();
        int schoolId = this.CurrentUser.SchoolID;
        DataSet ds = crm.QueryRoomAll(schoolId);
        Repeater1.DataSource = this.getPage(ds);
        Repeater1.DataBind();
    }

    public PagedDataSource getPage(DataSet ds)
    {
        this.pager.RecordCount = ds.Tables[0].Rows.Count;
        PagedDataSource pds = new PagedDataSource();
        pds.DataSource = ds.Tables[0].DefaultView;
        pds.AllowPaging = true;
        pds.CurrentPageIndex = pager.CurrentPageIndex - 1;
        pds.PageSize =pager.PageSize;
        return pds;
    }

}
